package com.qf.day06.Homework;

import java.util.Random;

public class Hero {
    private String name; // 名字
    private int power;  // 力量
    private int intellect;  // 力量
    private int agile;  // 敏捷

    /**
     * 徒手攻击（攻击力=力量的上下百分之20）
     */
    public void attack() {
        int y = (int) (Math.random() * (power + (power >= 0 ? 1 : -1)) * 0.2) * (Math.random() > 0.5 ? 1 : -1);
        System.out.println(toString() + "攻击力：" + (power + y));
    }


    public Hero() {
    }

    public Hero(String name, int power, int intellect, int agile) {
        this.name = name;
        this.power = power;
        this.intellect = intellect;
        this.agile = agile;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        this.power = power;
    }

    public int getIntellect() {
        return intellect;
    }

    public void setIntellect(int intellect) {
        this.intellect = intellect;
    }

    public int getAgile() {
        return agile;
    }

    public void setAgile(int agile) {
        this.agile = agile;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "name='" + name + '\'' +
                ", power=" + power +
                ", intellect=" + intellect +
                ", agile=" + agile +
                '}';
    }
}
